<template>
  <el-dialog
    title="批阅分数"
    :visible.sync="visible"
    :append-to-body="true">
    <p class="part-title" style="margin-top: 10px;">学生账号：{{studentAccount}}</p>
    <p class="part-title" style="margin-top: 10px;">学生姓名：{{studentName}}</p>
    <p class="part-title" style="margin-top: 10px;">学生姓名：{{studentBelong}}</p>
    <p class="part-title"  ><span style="float: left;margin-top: 1px;"">分数批阅</span>
      <el-form  :model="dataForm"  ref="dataForm" @keyup.enter.native="dataFormSubmit()"style="float: left;margin-left: 10px;margin-top: -5px;"">
       <el-form-item   prop="score">
         <el-input-number v-model="dataForm.score"  :min="0" :max="100" ></el-input-number>
        </el-form-item>
      </el-form>
    </p>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  /* eslint-disable */
  export default {
    data () {
      return {
        visible: false,
        id:'',
        studentName:'',
        studentBelong:'',
        studentAccount:'',
        dataForm: {
          score:''
        },
      }
    },
    computed: {
      account: {
        get () { return this.$store.state.user.account }
      },
      mainTabs: {
        get () { return this.$store.state.common.mainTabs },
        set (val) { this.$store.commit('common/updateMainTabs', val) }
      }
    },
    methods: {
      // 初始化
      init (id,studentName,studentBelong,studentAccount,score) {
        this.visible = true
        this.id = id,
        this.studentName = studentName,
        this.studentBelong = studentBelong,
        this.studentAccount = studentAccount,
        this.dataForm.score = score
      },
      // 表单提交
      dataFormSubmit () {
            this.$http({
              url: this.$http.adornUrl('/courses/editStudentExperiment'),
              method: 'post',
              data: this.$http.adornData({
                'id': this.id,
                'score': this.dataForm.score,
                'updateBy': this.account
              })
            }).then(({data}) => {
              if (data.success) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                   this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.message)
              }
            })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .part-title {
      margin: 20px 0;
      color: #000;
      padding-left: 1em;
      font-size: 16px;
      position: relative;
      display: inline-block;
      width: 100%;
  }
  .part-title:before{
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    width: 3px;
    height: 1em;
    background-color: #4976e8;
  }
  .el-button--primary {
      color: #fff;
      background-color: #273471 !important;
      border-color: #273471 !important;
  }
</style>
